package com.sike.netty.jinjie.channelhandler.custom;

import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CustomChannelHandler05 extends ChannelDuplexHandler {
    @Override
    public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception {
        log.info("{},接收客户端消息:{}",ctx,msg.toString());

        ctx.channel().writeAndFlush("服务端发送消息");
    }

    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
        log.info("{},出站消息:{}",ctx.channel(),msg.toString());

        super.write(ctx, msg, promise);
    }
}
